package net.xumf.support.enums;

import lombok.Getter;
import net.xumf.support.exception.NotFoundEnumInfoException;

import java.util.Arrays;

@Getter
public enum ReportJiraType {

    PROJECT("project", "p.pname"),
    CARD("card", "ji.summary"),
    ASSIGNEE("assignee", "ji.assignee"),
    REPORTER("reporter", "ji.reporter"),
    ASSIGNEE_NAME("assignee_name", "cua.last_name"),
    REPORTER_NAME("reporter_name", "cur.last_name"),
    CREATED("created", "ji.created"),
    UPDATED("updated", "ji.updated"),
    CUSTOM_FIELD("custom_field", "cfv.stringvalue"),
    TYPE_NAME("type_name", "it.pname"),
    STATUS_NAME("status_name", "st.pname"),
    SPRINT_NAME("sprint_name", "sp.\"NAME\""),
    FIX_VERSION("fix_version", "cifx.newstring"),
    ;

    ReportJiraType(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private String code;
    private String msg;

    public static ReportJiraType getByCode(String code) {
        return Arrays.stream(values()).filter(o -> o.code.equals(code)).findAny()
                .orElseThrow(() -> new NotFoundEnumInfoException(CodeEnum.ENUM_NOT_FOUND_ERROR));
    }
}
